package com.yanq.liancar.adapter;

import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.yanq.liancar.R;
import com.yanq.liancar.bean.ServiceTypeBean;
import com.yanq.liancar.util.LogUtils;

import java.util.List;

public class ServiceTypeAdapter extends BaseAdapter {
    private Context context;
    public List<Integer> datas;
    private LayoutInflater layoutInflater;

    public ServiceTypeAdapter(Context context, List<Integer> list) {
        this.context = context;

        this.datas = list;

        layoutInflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Log.e("dasdadasda", "asdadada" + "++++++++" + datas.size());
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = layoutInflater.inflate(R.layout.item_service_type, parent, false);
            holder.textView = convertView.findViewById(R.id.xiche);
            holder.imageView = convertView.findViewById(R.id.img_service);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        if (1 == datas.get(position)) {
            holder.textView.setText("精致洗车");
            holder.imageView.setImageResource(R.mipmap.xiche);
        } else if (2 == datas.get(position)) {
            holder.textView.setText("标准洗车");
            holder.imageView.setImageResource(R.mipmap.xiche2);
        } else if (3 == datas.get(position)) {
            holder.textView.setText("美容养护");
            holder.imageView.setImageResource(R.mipmap.meirong  );
        } else if (4 == datas.get(position)) {
            holder.textView.setText("保养维修");
            holder.imageView.setImageResource(R.mipmap.baoyang);
        } else if (5== datas.get(position)) {
            holder.textView.setText("钣金喷漆");
            holder.imageView.setImageResource(R.mipmap.penqi);
        } else if (6==datas.get(position)){
            holder.textView.setText("代办服务");
            holder.imageView.setImageResource(R.mipmap.daiban);
        }else if (7==datas.get(position)){
            holder.textView.setText("全车打蜡");
            holder.imageView.setImageResource(R.mipmap.fuwu_dala);
        }

        return convertView;
    }

    static class ViewHolder {
        TextView textView;
        ImageView imageView;
    }

    public void setData(List<Integer> list) {
        this.datas = list;
        notifyDataSetChanged();
        Log.e("dasdadasda", "asdadada" + "=========" + list.size());

    }
}
